<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class TongOrder extends Model
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'tong_order';

    protected $guarded = [];


    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function userInfo(){
        return $this->hasOne(TongUser::class,'id','u_id');
    }

    public function orderAddress(){
        return $this->hasOne(TongUserAddress::class,'id','address_id');
    }

    public function orderGoods(){
        return $this->hasOne(TongGood::class,'id','goods_id');
    }
    /**
     * @param $value
     * @return string
     */
    public function getOrderGoodsInfoAttribute($value)
    {
        return json_decode($value,true);
    }

    /**
     * @param $value
     * @return mixed
     */
    public function getOrderGroupGoodsInfoAttribute($value)
    {
        return json_decode($value,true);
    }

    /**
     * @param $value
     * @return void
     */
    public function getOrderAddressInfoAttribute($value){
        return json_decode($value,true);
    }

}
